﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using eTMS.Controllers.LoaiGiayToService;
using eTMS.Controllers;
using eTMS.Commons;
namespace eTMS.Controls{
   public class ComboBoxLoaiGiayTo : ComboBoxBindingBase<LoaiGiayToEntity>
   {
		public ComboBoxLoaiGiayTo(){
	    }
		//Bind data to txtLoaiGiayTo
        public override void BindData(){
		    List<LoaiGiayToEntity>lsLoaiGiayTo = new List<LoaiGiayToEntity>(LoaiGiayToController.ListLoaiGiayToStatic.ToArray());
			lsLoaiGiayTo=FilterList(lsLoaiGiayTo);
		    if(IsAddChooseItem){
				LoaiGiayToEntity eChooseItem = new LoaiGiayToEntity();
				eChooseItem.TenLoaiGiayTo = Constants.CHOOSE_ITEM;
				lsLoaiGiayTo.Insert(0,eChooseItem);
			}		
		    if(IsAddAllItem){
				LoaiGiayToEntity eChooseItem = new LoaiGiayToEntity();
                eChooseItem.TenLoaiGiayTo = Constants.APP_ALL;
				lsLoaiGiayTo.Insert(0,eChooseItem);
			}
            this.DisplayMember = "TenLoaiGiayTo";
		    object currentSelected=this.SelectedValue;
		    this.ValueMember = "LoaiGiayTo_ID";
		    this.DataSource = lsLoaiGiayTo;
		    if(currentSelected==null){
				if(this.Items.Count>0){
					this.SelectedIndex=0;
				}
            }
            else{
					this.SelectedValue = currentSelected;
					if(this.SelectedValue==null){
						if(this.Items.Count>0){
						this.SelectedIndex=0;
					}
                }
            }
        }
	}
}
